/*     */ package com.qmsk.business.store.giverule.controller;
/*     */ 
/*     */ import com.qmsk.business.store.giverule.dao.GiveRuleDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"giveRule"})
/*     */ public class GiveRuleController
/*     */ {
/*  42 */   private static final Logger logger = Logger.getLogger(GiveRuleController.class);
/*     */ 
/*     */   @Autowired
/*     */   private GiveRuleDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/sentInfo/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOpt2ShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  52 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  54 */       Map params = new HashMap();
/*  55 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*  56 */       MapUtils.addToMap(params, "status", 
/*  57 */         RequestUtils.getInt(request, "status"));
/*  58 */       MapUtils.addPercentToMap(params, "name", 
/*  59 */         RequestUtils.getString(request, "name"));
/*  60 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  61 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  63 */       logger.error(e);
/*  64 */       ResponseUtils.setErrorMsgResponse(
/*  65 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  74 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  76 */       Map params = new HashMap();
/*  77 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*  78 */       MapUtils.addToMap(params, "status", 
/*  79 */         RequestUtils.getInt(request, "status"));
/*  80 */       MapUtils.addPercentToMap(params, "name", 
/*  81 */         RequestUtils.getString(request, "name"));
/*     */ 
/*  83 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  84 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  86 */       logger.error(e);
/*  87 */       ResponseUtils.setErrorMsgResponse(
/*  88 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/*  96 */       Map params = new HashMap();
/*  97 */       MapUtils.addToMap(params, "id", id);
/*  98 */       MapUtils.addToMap(params, "status", 
/*  99 */         RequestUtils.getInt(request, "status"));
/* 100 */       MapUtils.addPercentToMap(params, "name", 
/* 101 */         RequestUtils.getString(request, "name"));
/*     */ 
/* 103 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(params);
/* 104 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 106 */       logger.error(e);
/* 107 */       ResponseUtils.setErrorMsgResponse(
/* 108 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId)
/*     */   {
/*     */     try
/*     */     {
/* 126 */       int nResult = 0;
/* 127 */       String sData = RequestUtils.getStringOfData(request);
/* 128 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/* 130 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 131 */         nResult = this.dao.applyUpdates(p);
/* 132 */         if (nResult > 0)
/* 133 */           DbConnection.commit();
/*     */         else {
/* 135 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 139 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 140 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 141 */         response);
/*     */     } catch (Exception e) {
/* 143 */       logger.error(e);
/* 144 */       DbConnection.rollback();
/* 145 */       ResponseUtils.setErrorMsgResponse(
/* 146 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 147 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}/{id}/{sendRange}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("id") Long id, @PathVariable("sendRange") Integer sendRange)
/*     */   {
/*     */     try
/*     */     {
/* 166 */       int nResult = 0;
/* 167 */       String sData = RequestUtils.getStringOfData(request);
/* 168 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 169 */       if ((p != null) && (p.isExistsUpdateRows())) {
/* 170 */         if (((GsonHeadOneRow)p.getListUpdateRows().get(0)).getValueOfName("id") == null) {
/* 171 */           ((GsonHeadOneRow)p.getListUpdateRows().get(0)).autoAddHeadData("id", id);
/*     */         }
/*     */ 
/* 174 */         nResult = this.dao.applyUpdates(p);
/* 175 */         if (nResult > 0)
/* 176 */           DbConnection.commit();
/*     */         else {
/* 178 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 182 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 183 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 184 */         response);
/*     */     } catch (Exception e) {
/* 186 */       logger.error(e);
/* 187 */       DbConnection.rollback();
/* 188 */       ResponseUtils.setErrorMsgResponse(
/* 189 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 190 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 206 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 208 */       String[] strParams = id.split(",");
/* 209 */       int nResult = this.dao.deleteParams(strParams);
/* 210 */       if (nResult > 0)
/* 211 */         DbConnection.commit();
/*     */       else {
/* 213 */         DbConnection.rollback();
/*     */       }
/* 215 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 216 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 217 */         response);
/*     */     } catch (Exception e) {
/* 219 */       DbConnection.rollback();
/* 220 */       logger.error(e);
/* 221 */       ResponseUtils.setErrorMsgResponse(
/* 222 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 223 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.giverule.controller.GiveRuleController
 * JD-Core Version:    0.5.3
 */